package main

import "fmt"

//type1
var s1 []int
//type2
var s2 []int = make([]int,5)
//type3
var s3 []int = make([]int,5,7)
func main() {
	s4:=make([]int,5)
	s5:=make([]int,5,7)

	s6:=make([]int,0)

	printSliceInfo(s1)
	printSliceInfo(s2)
	printSliceInfo(s3)
	printSliceInfo(s4)
	printSliceInfo(s5)

	if s1 == nil{
		fmt.Println("s1为nil","len(s1) = ",len(s1))
	}
	printSliceInfo(s6)
	if s6 == nil{
		fmt.Println("s6为nil","len(s6) = ",len(s6))
	}else {
		if s1 == nil{
			fmt.Println("s6不为nil","len(s6) = ",len(s6))
		}
	}
}

func printSliceInfo(x []int)  {
	fmt.Printf("len=%d,cap=%d,slice=%v \n",len(x),cap(x),x)
}
